//
//  PlistCommon.m
//  AppleMarket
//
//  Created by yangy on 25/10/2018.
//  Copyright © 2018 szgsy. All rights reserved.
//

#import "PlistCommon.h"

@implementation PlistCommon

+ (BOOL) saveLoginMode:(LoginModel*) m
{
    NSString *jsonStr = [m yy_modelToJSONString];
    if(kStringIsEmpty(jsonStr))
        return NO;
    [kUserDefaults setObject:jsonStr forKey:kPlistLoginMode];
    return [kUserDefaults synchronize];
}

+ (LoginModel*) loginModel
{
    NSString *jsonStr = [kUserDefaults objectForKey:kPlistLoginMode];
    if(kStringIsEmpty(jsonStr))
        return nil;
    return [LoginModel yy_modelWithJSON:jsonStr];
}

+ (void)clearLoginModel
{
    [kUserDefaults setObject:@"" forKey:kPlistLoginMode];
}

+ (BOOL) hiddenAsset
{
    NSString *key = [NSString stringWithFormat:@"%ld",[PlistCommon loginModel].UserID];
    return [kUserDefaults boolForKey:[key md5]];
}

+ (BOOL) saveHiddenAsset:(BOOL) isShow
{
    if(![PlistCommon loginModel] || [PlistCommon loginModel].UserID == 0)
        return NO;
    NSString *key = [NSString stringWithFormat:@"%ld",[PlistCommon loginModel].UserID];
    [kUserDefaults setBool:isShow forKey:[key md5]];
    
    return [kUserDefaults synchronize];
}

@end
